﻿using System.ServiceProcess;
using CrawlServiceCore.Crawl;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace SharePointCrawlService
{
    public class SharePointCrawlService : ServiceBase
    {
        public SharePointCrawlService()
        {
            InitializeComponent();
            //this.ServiceName = "SharePointCrawlService";
            //this.CanStop = false;
            //this.CanPauseAndContinue = false;
            //this.AutoLog = true;
        }

        #region Overrides
        protected override void OnStart(string[] args)
        {
            LogWriter logIt = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
            CrawlBase newRun = new CrawlBase(logIt, new EmailHandler());
            newRun.StartCrawling();
            this.Stop();
        }

        //protected override void OnStop()
        //{
        //}
        #endregion

        public static void Main()
        {
            System.ServiceProcess.ServiceBase.Run(new SharePointCrawlService());
        }

        private void InitializeComponent()
        {
            // 
            // SharePointCrawlService
            // 
            this.ServiceName = "SharePointCrawlService";

        }
    }
}